package cn.wolfcode.wolf2w.search.service.impl;

import cn.wolfcode.wolf2w.search.domain.TravelEs;
import cn.wolfcode.wolf2w.search.repository.TravelEsRepository;
import cn.wolfcode.wolf2w.search.service.ITravelEsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class TravelEsServiceImpl implements ITravelEsService {

    @Autowired
    private TravelEsRepository TravelEsRepository;

    @Override
    public void save(TravelEs TravelEs) {
        TravelEsRepository.save(TravelEs);
    }

    @Override
    public void update(TravelEs TravelEs) {
        TravelEsRepository.save(TravelEs);
    }

    @Override
    public void dilete(String id) {
        TravelEsRepository.deleteById(id);
    }

    @Override
    public TravelEs get(String id) {
        return TravelEsRepository.findById(id).orElse(null);
    }

    @Override
    public List<TravelEs> list() {
        ArrayList<TravelEs> list = new ArrayList<>();
        Iterable<TravelEs> all = TravelEsRepository.findAll();
        all.forEach(item -> list.add(item));
        return list;
    }
}
